import { createDiscreteApi } from "naive-ui";
import { storage } from "@/utils/Storage";
import storageEnum from "@/enums/storageEnum";

// 获取当前主题（假设你的主题存储在 Vuex/Pinia 或 localStorage 中）
function getCurrentTheme() {
  // 这里根据你的实际项目获取主题
  return storage.get(storageEnum.UI_THEME) || "light";
}

// 创建自适应的消息组件
const { message, notification, dialog, loadingBar } = createDiscreteApi(
  ["message", "notification", "dialog", "loadingBar"],
  {
    configProviderProps: {
      theme: getCurrentTheme() === "dark" ? window.$darkTheme : null,
    },
  },
);

export { message, notification, dialog, loadingBar };
